/*
 * @Author: 0x9DEFA478
 * @Date: 2021-09-08 15:11:21
 * @LastEditTime: 2021-09-29 11:58:55
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "GUI_User_Page.h"
#include "Peripheral.h"






// static void BackCallback(void* page){
//   H_UI_Page* Page;
//   Page=page;
//   if(Page->UserInstence!=NULL){
//     H_StringItem_EventBack(Page->UserInstence);
//   }else{
//     H_UI_ExitSelect(Page->Parent);
//   }
// }

static void EnterCallback(void* page){
  H_UI_Page* Page;
  Page=page;

  H_UI_ExitSelect(Page->Parent);
}

// static void AddCallback(void* page){
//   H_UI_Page* Page;
//   Page=page;
//   if(Page->UserInstence!=NULL){
//     H_StringItem_EventAdd(Page->UserInstence);
//   }
// }

// static void SubCallback(void* page){
//   H_UI_Page* Page;
//   Page=page;
//   if(Page->UserInstence!=NULL){
//     H_StringItem_EventSub(Page->UserInstence);
//   }
// }

// static void EnterPageCallback(void* page){
// }

// static void ExitPageCallback(void* page){
// }

static void DisplayPageCallback(void* page){
  H_UI_Page* Page;

  H_Graphics_Area_Param Param;

  char* str;
  unsigned char strBuffer[32];
  int strWidth0;
  int strHeight0;
  int strWidth1;
  int strHeight1;

  H_Malloc_Info info;


  Page=page;


  GUI_User_ClearBitmap(GUI_User_GetDrawStringBitmap());

  if(((H_UI*)Page->Parent)->IsSelect==0){
    //无选中

    str="RC522 Demo";
    H_Font_GetStringSize(Font_ASCII_Fixsys,str,&strWidth0,&strHeight0);
    GUI_User_DrawString(str,Font_ASCII_Fixsys,0,(128-strWidth0)/2,0,127,63);

    Param.S=Bitmap_0x9DEFA478_Logo;
    Param.D=GUI_User_GetDrawStringBitmap();
    Param.sX=0;
    Param.sY=0;
    Param.dX=0;
    Param.dY=20;
    Param.Width=Param.S->Width;
    Param.Height=Param.S->Height;
    H_Graphics_L1Vertical_CopyTo_L1Vertical(&Param);
    
    str="V1.0";
    H_Font_GetStringSize(Font_ASCII_H,str,&strWidth0,&strHeight0);
    GUI_User_DrawString(str,Font_ASCII_H,0,128-strWidth0,20,127,63);

    str="0x9DEFA478";
    H_Font_GetStringSize(Font_ASCII_Fixsys,str,&strWidth0,&strHeight0);
    GUI_User_DrawString(str,Font_ASCII_Fixsys,0,128-strWidth0,48,127,63);

    str="BY";
    H_Font_GetStringSize(Font_ASCII_H,str,&strWidth1,&strHeight1);
    GUI_User_DrawString(str,Font_ASCII_H,0,128-strWidth0-strWidth1,51,127,63);

  }else{
    //选中

    MemoryMalloc_SRAM_GetInfo(&info);
    str=H_String(strBuffer,"SRAMFREE:{i}BYTE",info.FreeSize);
    GUI_User_DrawString(str,Font_ASCII_H,0,0,0,127,63);

    str=H_String(strBuffer,"STACKLOAD:{f.2}%",(float)H_TS_GetStackUtilization()/10.0f);
    GUI_User_DrawString(str,Font_ASCII_H,0,0,8,127,63);


  }
}

H_StringItem* GUI_User_Page_Info_Init(H_UI* h_ui,H_UI_Callbacks* Callbacks){

  GUI_User_Page_GetDefaultCallbacks(Callbacks);
  Callbacks->DisplayPageCallback=DisplayPageCallback;
  Callbacks->EnterCallback=EnterCallback;

  return NULL;
}

void GUI_User_Page_Info_DeInit(H_StringItem* stringitem){
}


